%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This is part of the set of files that accompany the article:       %
%Mankiw, N. Gregory and Ricardo Reis (2007) "Sticky Information in  %
%General Equilibrium," Journal of the European Economic Association,%
%forthcoming. See the appendix of the NBER or CEPR working paper    %
%versions for a detailed explanation of the algorithms.             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Please cite if you use the programs. I do not provide tech support.%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Last revised: August 30, 2006                                      %
%Written by: Ricardo Reis                                           %
%Input: none                                                        %
%Output: Displays the Prior section of Table 1.                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear; clc

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
disp('     RESULTS ON ESTIMATING PERVASIVE STICKINESS     ');
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
disp(' ')

disp('##########################################')
disp('########    PRIOR DISTRIBUTION    ########')
disp('##########################################')
disp(' ')
Pmean=[11 11 0.7 0.25^2 0.7 0.25^2 0.7 0.25^2];
Pvar= [10 10 0.05 0.25  0.05   0.25   0.05  0.25];
Ppar(2,1)=(Pmean(1)-1)/Pvar(1); Ppar(1,1)=Ppar(2,1)*(Pmean(1)-1);
Ppar(2,2)=(Pmean(2)-1)/Pvar(2); Ppar(1,2)=Ppar(2,2)*(Pmean(2)-1);
Ppar(1,3)=((1-Pmean(3))*Pmean(3)^2)/Pvar(3)-Pmean(3); Ppar(2,3)=Ppar(1,3)*(1/Pmean(3)-1);
Ppar(1,4)=4+(2*Pmean(4)^2)/(Pvar(4)); Ppar(2,4)=(Ppar(1,4)-2)*Pmean(4)/Ppar(1,4);
Ppar(1,5)=((1-Pmean(5))*Pmean(5)^2)/Pvar(5)-Pmean(5); Ppar(2,5)=Ppar(1,5)*(1/Pmean(5)-1);
Ppar(1,6)=4+(2*Pmean(6)^2)/(Pvar(6)); Ppar(2,6)=(Ppar(1,6)-2)*Pmean(6)/Ppar(1,6);
Ppar(1,7)=((1-Pmean(7))*Pmean(7)^2)/Pvar(7)-Pmean(7); Ppar(2,7)=Ppar(1,7)*(1/Pmean(7)-1);
Ppar(1,8)=4+(2*Pmean(8)^2)/(Pvar(8)); Ppar(2,8)=(Ppar(1,8)-2)*Pmean(8)/Ppar(1,8);
Ppar(1,4)=0.5*Ppar(1,4); Ppar(1,6)=0.5*Ppar(1,6); Ppar(1,8)=0.5*Ppar(1,8);
Ppar(2,4)=Ppar(1,4)*Ppar(2,4); Ppar(2,6)=Ppar(1,6)*Ppar(2,6); Ppar(2,8)=Ppar(1,8)*Ppar(2,8);
disp('Parameters of distributions:'); disp(Ppar)
disp(' ')
PriorMoments=[1+gaminv(0.025,Ppar(1,1),inv(Ppar(2,1))) 1+gaminv(0.975,Ppar(1,1),inv(Ppar(2,1)))];
PriorMoments=[PriorMoments;1+gaminv(0.025,Ppar(1,2),inv(Ppar(2,2))) 1+gaminv(0.975,Ppar(1,2),inv(Ppar(2,2)))];
PriorMoments=[PriorMoments;betainv(0.025,Ppar(1,3),Ppar(2,3)) betainv(0.975,Ppar(1,3),Ppar(2,3))];
PriorMoments=[PriorMoments;sqrt(1./gaminv(.975,Ppar(1,4),inv(Ppar(2,4)))) sqrt(1./gaminv(.025,Ppar(1,4),inv(Ppar(2,4))))];
PriorMoments=[PriorMoments;betainv(0.025,Ppar(1,5),Ppar(2,5)) betainv(0.975,Ppar(1,5),Ppar(2,5))];
PriorMoments=[PriorMoments;sqrt(1./gaminv(.975,Ppar(1,6),inv(Ppar(2,6)))) sqrt(1./gaminv(.025,Ppar(1,6),inv(Ppar(2,6))))];
PriorMoments=[PriorMoments;betainv(.025,Ppar(1,7),Ppar(2,7)) betainv(0.975,Ppar(1,7),Ppar(2,7))];
PriorMoments=[PriorMoments;sqrt(1./gaminv(.975,Ppar(1,8),inv(Ppar(2,8)))) sqrt(1./gaminv(.025,Ppar(1,8),inv(Ppar(2,8))))];
PriorMoments=PriorMoments';
disp('95% confidence interval from prior'); disp(PriorMoments)
disp(' ')
temp=gamrnd(Ppar(1,1),inv(Ppar(2,1)),100000,1); PriorEst=[1+mean(temp) std(temp)];
temp=gamrnd(Ppar(1,2),inv(Ppar(2,2)),100000,1); PriorEst=[PriorEst; 1+mean(temp) std(temp)];
temp=betarnd(Ppar(1,3),Ppar(2,3),100000,1); PriorEst=[PriorEst; mean(temp) std(temp)];
temp=sqrt(1./gamrnd(Ppar(1,4),inv(Ppar(2,4)),100000,1)); PriorEst=[PriorEst; mean(temp) std(temp)];
temp=betarnd(Ppar(1,5),Ppar(2,5),100000,1); PriorEst=[PriorEst; mean(temp) std(temp)];
temp=sqrt(1./gamrnd(Ppar(1,6),inv(Ppar(2,6)),100000,1)); PriorEst=[PriorEst; mean(temp) std(temp)];
temp=betarnd(Ppar(1,7),Ppar(2,7),100000,1); PriorEst=[PriorEst; mean(temp) std(temp)];
temp=sqrt(1./gamrnd(Ppar(1,8),inv(Ppar(2,8)),100000,1)); PriorEst=[PriorEst; mean(temp) std(temp)];
PriorEst=PriorEst';
disp('Mean and StDev from priors'); disp(PriorEst)
disp(' ')
disp('Theroetical Mean and StDev of priors:'); disp([Pmean; sqrt(Pvar)])
disp(' ')

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
disp('                 THE END                            ');
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');

